package datasv.courseSelect_datasv;

import java.util.ArrayList;
import java.util.List;

import data.datafactory.DatabaseOperator;
import po.SelectRecordPO;

public class GetSelectRecord {
	public static void main(String[] args) {
		System.out.println(new GetSelectRecord().getSelectRecord("00101130010"));
	}
	public List<SelectRecordPO> getSelectRecord(String courseID){
		return getInSql(courseID);
	}
	private List<SelectRecordPO> getInSql(String courseID){
		String collegeID=courseID.substring(0,3);
		ArrayList<SelectRecordPO> list=new ArrayList<SelectRecordPO>();
		DatabaseOperator op=new DatabaseOperator("college"+collegeID);
		if(!op.ifDatabaseExist()||!op.ifIDExist("course_list", courseID)){
			return list;
		}
		if(!op.ifIDExist("course_select_record", courseID)){
			return list;
		}
	
		ArrayList<String[]> l2=op.sort(courseID, "course_select_record", 1, 2);
	
		for (int i = 0; i < l2.size(); i++) {
			list.add(new SelectRecordPO(l2.get(i)[0],l2.get(i)[1]));
		}
		return list;
	}
}
